package com.like.banzipao.server

import com.like.banzipao.server.model.Poker
import com.like.banzipao.server.model.Suit
import com.like.banzipao.server.util.PlayPokerType
import com.like.banzipao.server.util.PlayRuleUtils
import org.junit.Test

class ExampleUnitTest {
    @Test
    fun addition_isCorrect() {
        val prePlayPokers = listOf(
            Poker(1, "3", Suit.SPADE),
            Poker(1, "3", Suit.SPADE),
            Poker(1, "3", Suit.SPADE),
            Poker(1, "4", Suit.SPADE),
            Poker(1, "4", Suit.SPADE),
            Poker(1, "4", Suit.SPADE),
            Poker(1, "5", Suit.SPADE),
            Poker(1, "5", Suit.SPADE),
            Poker(1, "5", Suit.SPADE),
        )
        val curPlayPokers = listOf(
            Poker(1, "4", Suit.SPADE),
            Poker(1, "4", Suit.SPADE),
            Poker(1, "4", Suit.SPADE),
            Poker(1, "4", Suit.SPADE),
            Poker(1, "5", Suit.SPADE),
            Poker(1, "5", Suit.SPADE),
            Poker(1, "5", Suit.SPADE),
            Poker(1, "5", Suit.SPADE),
            Poker(1, "6", Suit.SPADE),
            Poker(1, "6", Suit.SPADE),
            Poker(1, "6", Suit.SPADE),
            Poker(1, "6", Suit.SPADE),
        )
        assert(PlayRuleUtils.isValid(prePlayPokers, curPlayPokers))
    }

    @Test
    fun DAN_ZHANG() {
        val pokers = listOf(
            Poker(1, "3", Suit.SPADE),
        )
        assert(PlayRuleUtils.getPlayType(pokers) == PlayPokerType.DAN_ZHANG)
    }

    @Test
    fun DUI_ZI() {
        val pokers = listOf(
            Poker(1, "3", Suit.SPADE),
            Poker(1, "3", Suit.SPADE),
        )
        assert(PlayRuleUtils.getPlayType(pokers) == PlayPokerType.DUI_ZI)
    }

    @Test
    fun LIAN_ZI() {
        val pokers = listOf(
            Poker(1, "3", Suit.SPADE),
            Poker(1, "4", Suit.SPADE),
            Poker(1, "5", Suit.SPADE),
        )
        assert(PlayRuleUtils.getPlayType(pokers) == PlayPokerType.LIAN_ZI)
    }

    @Test
    fun ZHA_DAN_SAN_ZHANG() {
        val pokers = listOf(
            Poker(1, "3", Suit.SPADE),
            Poker(1, "3", Suit.SPADE),
            Poker(1, "3", Suit.SPADE),
        )
        assert(PlayRuleUtils.getPlayType(pokers) == PlayPokerType.ZHA_DAN_SAN_ZHANG)
    }

    @Test
    fun BAN_ZI_PAO() {
        val pokers = listOf(
            Poker(1, "3", Suit.SPADE),
            Poker(1, "3", Suit.SPADE),
            Poker(1, "4", Suit.SPADE),
            Poker(1, "4", Suit.SPADE),
            Poker(1, "5", Suit.SPADE),
            Poker(1, "5", Suit.SPADE),
            Poker(1, "6", Suit.SPADE),
            Poker(1, "6", Suit.SPADE),
        )
        assert(PlayRuleUtils.getPlayType(pokers) == PlayPokerType.BAN_ZI_PAO)
    }

    @Test
    fun ZHA_DAN_SI_ZHANG() {
        val pokers = listOf(
            Poker(1, "3", Suit.SPADE),
            Poker(1, "3", Suit.SPADE),
            Poker(1, "3", Suit.SPADE),
            Poker(1, "3", Suit.SPADE),
        )
        assert(PlayRuleUtils.getPlayType(pokers) == PlayPokerType.ZHA_DAN_SI_ZHANG)
    }

    @Test
    fun HUO_JIAN_DAN() {
        val pokers = listOf(
            Poker(1, "3", Suit.SPADE),
            Poker(1, "3", Suit.SPADE),
            Poker(1, "3", Suit.SPADE),
            Poker(1, "4", Suit.SPADE),
            Poker(1, "4", Suit.SPADE),
            Poker(1, "4", Suit.SPADE),
            Poker(1, "5", Suit.SPADE),
            Poker(1, "5", Suit.SPADE),
            Poker(1, "5", Suit.SPADE),
            Poker(1, "6", Suit.SPADE),
            Poker(1, "6", Suit.SPADE),
            Poker(1, "6", Suit.SPADE),
        )
        assert(PlayRuleUtils.getPlayType(pokers) == PlayPokerType.HUO_JIAN_DAN)
    }

    @Test
    fun GUN_TONG_PAO() {
        val pokers = listOf(
            Poker(1, "3", Suit.SPADE),
            Poker(1, "3", Suit.SPADE),
            Poker(1, "3", Suit.SPADE),
            Poker(1, "3", Suit.SPADE),
            Poker(1, "4", Suit.SPADE),
            Poker(1, "4", Suit.SPADE),
            Poker(1, "4", Suit.SPADE),
            Poker(1, "4", Suit.SPADE),
            Poker(1, "5", Suit.SPADE),
            Poker(1, "5", Suit.SPADE),
            Poker(1, "5", Suit.SPADE),
            Poker(1, "5", Suit.SPADE),
        )
        assert(PlayRuleUtils.getPlayType(pokers) == PlayPokerType.GUN_TONG_PAO)
    }

    @Test
    fun checkTIAN_BAO() {
        val pokers = listOf(
            Poker(1, "3", Suit.SPADE),
            Poker(2, "4", Suit.SPADE),
            Poker(3, "5", Suit.SPADE),
            Poker(4, "6", Suit.SPADE),
            Poker(5, "7", Suit.SPADE),
            Poker(6, "8", Suit.SPADE),
            Poker(7, "9", Suit.SPADE),
            Poker(8, "10", Suit.SPADE),
            Poker(9, "J", Suit.SPADE),
            Poker(10, "Q", Suit.SPADE),
            Poker(11, "K", Suit.SPADE),
            Poker(12, "A", Suit.SPADE),
            Poker(13, "2", Suit.SPADE)
        )
        assert(PlayRuleUtils.getPlayType(pokers) == PlayPokerType.TIAN_BAO)
    }
}
